//Add a event to open the dropdown menu every time the user hovers over the item.
function addHoverEvent(){
	$(".dropdown").mouseenter(function(){
		$(this).addClass("open");
	});

	$(".dropdown").mouseleave(function(){
		$(this).removeClass("open");
	});
}

//Add a event to open the menuitem on the index page every time the user hovers over the item.
function addMenuHover(){
	$menuitems = $(".f-menu ul li .f-menuItem");
	$menuitems.mouseenter(function(){
		$(this).animate({'bottom':0},250);
		$(this).find(".f-subText").slideDown(250);
		$(this).find(".f-image").animate({'height':120},250);
		$(this).find(".f-subMenu").slideDown(250);
		$(this).find(".f-image .f-img").animate({bottom:'0'},250);
	});

	$menuitems.mouseleave(function(){
		$(this).animate({'bottom':"none"},250);
		$(this).find(".f-subText").slideUp(250);
		$(this).find(".f-image").animate({'height':50},250);
		$(this).find(".f-subMenu").slideUp(250);
		$(this).find(".f-image .f-img").animate({bottom:'-40px'},250);
	});
}

//Adjsting heigth for grid system
function gridHeight(){
	$('.f-grid-heigth').each(function(){
		var parentHeight = $(this).parent().height();
		$(this).height(parentHeight-40);    
	});
	$('.f-grid-heigth-img').each(function(){
		var parentHeight = $(this).parent().height();
		$(this).height(parentHeight);    
	});
	
}

//Changes the urls for every page.
function AddLanguageUrls(){
	var $langItems = $(".f-language").find("li a"),
	re = new RegExp(window.location.hostname);
	url = String(window.location.href);
	$langItems.each(function(){
		if(url.indexOf("/de/")!=-1){
			url = url.replace(/de/,$(this).attr("href"));

		}else if(url.indexOf("/en/")!=-1){
			url = url.replace(/en/,$(this).attr("href"));

		}else if(url.indexOf("/es/")!=-1){
			url = url.replace(/es/,$(this).attr("href"));
			
		}else{
			url = url.replace(re,re+$(this).attr("href"));
		}
		url = url.replace(/\/\/\//,"//");
		$(this).attr("href",url);
	});
}

//Scrools the page down to the product info section
function scrollToProduct(){
	var product = $(".f-product-page")[0];
	var offset = $(product).offset();
	$("body,html").animate({
		scrollTop: offset.top
	},400)
}

function scrollMoreInfo(){
	$(window).scroll(function() {
		$(".see-more-arrow").fadeOut();
	});
	(function animateMoreInfo(){
		$(".see-more-arrow").animate(
			{bottom: 0},500,function(){
				$(".see-more-arrow").animate({bottom: 20},500,animateMoreInfo());
			});
	})();
}
//Bootstrap TABS trigger

